package com.cruise.system.userapi.feignapi;

import com.cruise.common.web.result.Result;
import com.cruise.system.userapi.dto.RegistUserDTO;
import com.cruise.system.userapi.dto.UpdateUserDataCountDTO;
import com.cruise.system.userapi.entity.SysRole;
import com.cruise.system.userapi.entity.SysUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author cruise
 */
@FeignClient("USERHANDLE-SERVER")
public interface FeignSystemApi {

    /**
     * 根据用户名查询
     * @param username
     * @return
     */
    @GetMapping("/sysuser/findByUsername")
    Result<SysUser> findByUsername( @RequestParam("username") String username);
    /**
     * 根据用户ID查询角色
     * @param id
     * @return
     */
    @GetMapping("/sysuser/getRoleByUserId")
    Result<List<SysRole>> getRoleByUserId(@RequestParam("id")String id);

    /**
     * 根据手机号查询
     * @param phone
     * @return
     */
    @GetMapping("/sysuser/findByPhone")
    Result<SysUser> findByPhone(@RequestParam("phone") String phone);

    /**
     * 注册接口
     * @param userDto
     * @return
     */
    @PostMapping("/sysuser/regist")
    Result<String> regist(@RequestBody RegistUserDTO userDto);

    /**
     * 根据ID查询用户
     * @param userId
     * @return
     */
    @PostMapping("/sysuser/findById")
    SysUser findById(@RequestParam("userId")String userId);

    /**
     * 查询手机号是否存在
     * @param phoneNumber
     * @return
     */
    @PostMapping("/sysuser/checkPhoneAvailable")
    Boolean checkPhoneAvailable(@RequestParam("phoneNumber")String phoneNumber);


    /**
     * 更新统计数据
     * @param updateUserDataCountDTO
     * @return
     */
    @PostMapping("/sysuser/updateUserDataCount")
    Result updateUserDataCount(@RequestBody UpdateUserDataCountDTO updateUserDataCountDTO);
}
